<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html">

    <body>
        <ui:composition template="../templates/default3.xhtml">
            <ui:define name="content">
                <h:form id="viewSupplier" binding="#{supplierManagerBean.loadUpdateSupplier}">
                    <p:panel id="viewSupplierPanel" header="View Supplier Information">
                        <p:messages />

                        <table border="0" width="100%">
                            <tr>
                                <td width="120px">Supplier Id:</td>
                                <td width="240px"> 
                                    <h:outputText id="supplierId" title="Supplier Id"
                                                  value="#{supplierManagerBean.supplierId}">
                                    </h:outputText>                              
                                </td>

                                <td width="80px">Company:</td>
                                <td> 
                                    <h:outputText id="company" title="Company"
                                                  value="#{supplierManagerBean.company}">
                                    </h:outputText>
                                </td>
                            </tr>      
                            <tr>
                                <td>Name:</td>
                                <td> 
                                    <h:outputText id="name" title="Name"
                                                  value="#{supplierManagerBean.name}">
                                    </h:outputText>
                                </td>
                                <td>Ranking:</td>
                                <td>                                                                                
                                    <h:outputText id="ranking" title="Ranking"
                                                  value="#{supplierManagerBean.ranking}">
                                    </h:outputText>
                                </td>
                            </tr>
                            <tr>
                                <td>Contact:</td>
                                <td>                                                                                
                                    <h:outputText id="contact" title="Contact"
                                                  value="#{supplierManagerBean.contact}">
                                    </h:outputText>
                                </td>
                                <td>Email:</td>
                                <td>
                                    <h:outputText id="email" title="Email"
                                                  value="#{supplierManagerBean.email}">
                                    </h:outputText>
                                </td>
                            </tr>     
                            <tr>
                                <td width ="80px" valign="top"> Comment:</td>
                                <td width="200px" valign="top" colspan="3">
                                    <h:outputText id="comment" style="width:160px;height:80px;" title="Comment" 
                                                  value="#{supplierManagerBean.comment}">
                                    </h:outputText>                                
                                </td>
                            </tr>        
                        </table>
                    </p:panel>
                    <p:panel header="Supplier's Company Address" id="updateSupplier2">
                        <table border="0" width="100%">
                            <tr>
                                <td width ="120px" valign="top" > Street:</td>
                                <td width="240px" valign="top"> 
                                    <h:outputText id="street" title="Street"
                                                  value="#{supplierManagerBean.street}">
                                    </h:outputText>
                                </td>
                                <td width="80px">City:</td>
                                <td>
                                    <h:outputText id="city" title="City"
                                                  value="#{supplierManagerBean.city}">
                                    </h:outputText>
                                </td>
                            </tr>
                            <tr>
                                <td valign ="top" >Postal: </td>
                                <td width="200px" valign ="top"> 
                                    <h:outputText id="postal" title="Email"
                                                  value="#{supplierManagerBean.postal}">
                                    </h:outputText>
                                </td>
                                <td valign ="top" >Country: </td>
                                <td>
                                    <h:outputText id="country" title="Country"
                                                  value="#{supplierManagerBean.country}">
                                    </h:outputText>
                                </td>
                            </tr>                
                        </table>
                    </p:panel>


                    <p:panel id="rawMaterialsPanel" header="Selling Types of Raw Material ">
                        <p:messages />
                        <table width="100%" border="0">
                            <tr>
                                <td colspan="2">
                                    <p:dataTable id="materials" var="material" value="#{supplierManagerBean.rawMaterialsSelling}"  
                                                 update="updateSupplier">
                                        <p:column filterBy="#{material.name}" headerText="Raw Material Name" filterMatchMode="contains">  
                                            <h:outputText value="#{material.name}" />  
                                        </p:column>                                        
                                    </p:dataTable>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2" align="center"><hr/>
                                    <p:commandButton id="btnBackFromViewSupplier" value="Back"
                                                     immediate="true" ajax="true"
                                                     title="Go back to the previous page."
                                                     actionListener="#{supplierManagerBean.back}"/>
                                    &nbsp;&nbsp;&nbsp;
                                    <p:commandButton id="btnUpdateSupplier" value="Update Supplier"
                                                     ajax="true" title="Update the supplier."
                                                     update="updateSupplierPanel"
                                                     actionListener="#{supplierManagerBean.updateSupplier}"/>
                                    &nbsp;&nbsp;&nbsp;
                                    <p:commandButton id="btnRemoveSupplier" value="Remove Supplier" 
                                                     onclick="confirmation.show()" type="button"
                                                     title="Remove the selected product." />
                                </td>
                            </tr>
                        </table>
                    </p:panel>
                    <p:confirmDialog  width="400" message="" header="Removing a Supplier" severity="alert" widgetVar="confirmation">
                        <f:facet name="message">
                            <h:outputText value="You are going to remove a supplier."/><br/>
                            <h:outputText value="Are you sure you want to continue?"/>
                        </f:facet>    
                        <table width="100%">
                            <tr>
                                <td align="center">
                                    <p:commandButton value="Yes" update="suppliersPanel" onclick="confirmation.hide()"
                                         actionListener="#{supplierManagerBean.removeSupplier}"/>
                        &nbsp;&nbsp;&nbsp;
                        <p:commandButton value="No" update="suppliersPanel" onclick="confirmation.hide()" type="button" />
                                </td>
                            </tr>
                        </table>
                        
                    </p:confirmDialog>
                </h:form>
            </ui:define>
        </ui:composition>
    </body>
</html>
